<template>
  <div class="box-item">
    <div class="box-item-title">{{ title }}</div>
    <v-chart :option="chartOption" style="width: 100%; height: 320px;"></v-chart>
  </div>
</template>

<script>
export default {
  name: 'box-item-three',
  props: {
    title: String,
    info: {
      type: Array,
      default () {
        return []
      }
    }
  },
  computed: {
    chartOption () {
      const info = this.info
      return {
        color: ['#50fdfc', '#e6b00e'],
        title: {
          show: false,
        },
        legend: {
          show: false
        },
        tooltip: {
          trigger: 'item'
        },
        grid: {
          left: '6%',
          top: '3%',
          bottom: '6%',
          containLabel: true
        },
        xAxis: {
          type: 'value',
          boundaryGap: [0, 0.01],
          axisLine: {
            lineStyle: {
              color: '#2b7ed6',
            }
          },
          splitLine: {
            lineStyle: {
              color: '#024287',
            }
          },
          axisLabel: {
            color: '#6b92b5',
          },
        },
        yAxis: {
          type: 'category',
          data: info.map(v => v.name).reverse(),
          axisLine: {
            lineStyle: {
              color: '#2b7ed6',
            }
          },
          splitLine: {
            lineStyle: {
              color: '#024287',
            }
          },
          axisLabel: {
            color: '#6b92b5',
          },
        },
        series: [
          {
            type: 'bar',
            data: info.map(v => v.value).reverse()
          }
        ]
      }
    }
  }
}
</script>

<style scoped>

</style>
